package com.example.blogdemo.repository;

import com.example.blogdemo.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author Anita
 * @Date 2017/12/13 11:50
 */
public interface UserRepository extends JpaRepository<User,Integer> {

    public User findById (Integer userId);

    public User findByName(String name);

    @Transactional
    @Modifying
    @Query(value = "delete from user where id = :id",nativeQuery = true)
    public void deleteById(@Param("id") Integer userId);



}
